Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove symlink, not target, in FileOp.Rm. #2474

Merged
merged 1 commit into from
Nov 18, 2021

Conversation

sipsma
Copy link
Collaborator

@sipsma sipsma commented Nov 18, 2021

Before this change, if the path provided to FileOp.Rm was a symlink then
the target of the symlink would be removed instead of the symlink
itself. Now, the symlink will be removed instead. However, any symlinks
present in the parent dirs of the specified path will still be resolved
before calling os.Remove; this change only results in the base of the
specified path not being followed.

Signed-off-by: Erik Sipsma [email protected]

@sipsma sipsma requested a review from tonistiigi November 18, 2021 20:13
Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add a cap for that in case anyone wants to detect the behavior change.

@@ -146,10 +146,12 @@ func rm(ctx context.Context, d string, action pb.FileActionRm) error {
}

func rmPath(root, src string, allowNotFound bool) error {
p, err := fs.RootPath(root, filepath.Join("/", src))
dir, base := filepath.Split(src)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean() the src for safety before. And validate base not empty?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Before this change, if the path provided to FileOp.Rm was a symlink then
the target of the symlink would be removed instead of the symlink
itself. Now, the symlink will be removed instead. However, any symlinks
present in the parent dirs of the specified path will still be resolved
before calling os.Remove; this change only results in the base of the
specified path not being followed.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
Copy link
Collaborator Author

sipsma commented Nov 18, 2021

I think we should add a cap for that in case anyone wants to detect the behavior change.

Added a cap in the update that's set server-side, but should the client actually set that anywhere in any requests? Or is it just cap the server sets that users can query if they want? I'm not that familiar with the whole cap system and see pre-existing caps following both patterns, so not sure what's right here.

@tonistiigi
Copy link
Member

but should the client actually set that anywhere in any requests?

Only if the client had an option like WithNoFollowSymlink. As there is no such option then with a server option user can just look up a value and marshal different llb based on it if needed.

@tonistiigi tonistiigi merged commit 8d02e47 into moby:master Nov 18, 2021
@sipsma sipsma deleted the file-rm-no-follow branch November 18, 2021 22:16
@crazy-max crazy-max added this to the v0.10.0 milestone Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants